//
//  AppDelegate.m
//  A_GOGO
//
//  Created by Liuiu on 16/1/15.
//  Copyright © 2016年 www.lanou3g.com. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"
#import "GameViewController.h"
#import "ActivityViewController.h"
#import "PresentViewController.h"
#import "SquareViewController.h"

#import "LeftDrawerViewController.h"
@interface AppDelegate ()

@end

@implementation AppDelegate
- (void)dealloc
{
    [_window release];
    [_MMDrawer release];
    [super dealloc];
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    

    ViewController *root=[[ViewController alloc]init];
    UINavigationController *navi =[[UINavigationController alloc]initWithRootViewController:root];

        //Home
    root.tabBarItem =[[UITabBarItem alloc]initWithTitle:@"首页" image:[UIImage imageNamed:@"shouye"] tag:1000];
    
    //Activity
    ActivityViewController *act =[[ActivityViewController alloc]init];
    UINavigationController *navi1 =[[UINavigationController alloc]initWithRootViewController:act];
    act.tabBarItem =[[UITabBarItem alloc]initWithTitle:@"活动" image:[UIImage imageNamed:@"huodong"] tag:2000];
    
    
    //Present
    PresentViewController *pre = [[PresentViewController alloc]init];
    UINavigationController *navi2 =[[UINavigationController alloc]initWithRootViewController:pre];
    pre.tabBarItem =[[UITabBarItem alloc]initWithTitle:@"礼包" image:[UIImage imageNamed:@"libao"] tag:4000];
    

    
    //Game
    GameViewController *game =[[GameViewController alloc]init];
    UINavigationController *navi3=[[UINavigationController alloc]initWithRootViewController:game];
    game.tabBarItem =[[UITabBarItem alloc]initWithTitle:@"游戏圈" image:[UIImage imageNamed:@"youxiquan"] tag:3000];
    
    
    //Square
    SquareViewController *square =[[SquareViewController alloc]init];
    UINavigationController *navi4 =[[UINavigationController alloc]initWithRootViewController:square];
    square.tabBarItem =[[UITabBarItem alloc]initWithTitle:@"广场" image:[UIImage imageNamed:@"guangchang"] tag:5000];
    //创建TabBar
    UITabBarController *tabBar =[[UITabBarController alloc]init];
    
    tabBar.viewControllers =@[navi, navi1, navi2, navi3, navi4];
    
//****** 创建抽屉
    LeftDrawerViewController *leftVC =[[LeftDrawerViewController alloc]init];
    self.MMDrawer = [[MMDrawerController alloc]initWithCenterViewController:tabBar leftDrawerViewController:leftVC];
    
    //设置抽屉的偏移量
    [self.MMDrawer setMaximumLeftDrawerWidth:330.0];
    
    //给抽屉添加手势(给划开打开的方法注了,用按钮打开)
    
//    [self.MMDrawer setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
    [self.MMDrawer setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
    
    
    
    self.window.rootViewController = _MMDrawer;
    [_window release];
    [root release];
    [navi release];
    [navi1 release];
    [navi2 release];
    [navi3 release];
    [navi4 release];
    [tabBar release];
    [leftVC release];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
